package com.leyou.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leyou.item.dto.SpecParamDTO;
import com.leyou.item.entity.SpecParam;
import com.leyou.item.mapper.SpecParamMapper;
import com.leyou.item.service.SpecParamService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author BaiZY on 2020/8/25.
 * @version 1.0
 */
@Service
public class SpecParamServiceImpl extends ServiceImpl<SpecParamMapper, SpecParam> implements SpecParamService {

    /**
     * 根据条件查询规格参数集合
     * @param cid
     * @param gid
     * @param searching
     * @return
     */
    @Override
    public List<SpecParamDTO> queryParamsByCondition(Long cid, Long gid, Boolean searching) {
        List<SpecParam> list = query().eq(cid != null, "category_id", cid)
                .eq(gid != null, "group_id", gid)
                .eq(searching != null, "searching", searching)
                .list();
        return SpecParamDTO.convertEntityList(list);
    }
}
